<include file="Public/header" />
<body>
    <link href="__PUBLIC__/Admin/css/H-ui.min.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="__PUBLIC__/Admin/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Admin/lib/layer/1.9.3/layer.js"></script>
	<link rel="stylesheet" href="__PUBLIC__/Admin/lib/layer/1.9.3/skin/layer.css" id="layui_layer_skinlayercss">
<style type="text/css">
        .col-lg-10 {
            margin: 12px auto;
            float: none;
            overflow: auto;
        }

        .input-text, .select-box {
            border-color: #ccc;
        }

        .input-control {
            float: left;
            margin-right: 8px;
        }

        input {
            font-size: 24px;
            font-weight: bolder;
        }
</style>

<div class="container">
    <div class="col-lg-10">
        <input class="input-text radius size-XL" id="saom" name="saom" type="text" placeholder="请扫描<{:C('scanorder.lang_name')}>"/>
        <span>*按Ctrl+0将焦点移到扫描筐</span>
    </div>
    <div class="col-lg-10">
        <input style="margin: 12px 0;" id="pack_weight" class="input-control input-text radius size-L" type="text"
               placeholder="包裹重量(KG)"/>
        <input id="sub" class="btn btn-success radius size-XL" type="button" value="确认"/>
    </div>
</div>
<script type="text/javascript">
    $("#saom").focus();
    $(document).keydown(function (event) {
        if (event.ctrlKey && event.keyCode == 48) {
            $("#saom").focus();
        }
    });
    var index = 0;//此时状态为扫描<{:C("scanorder.lang_name")}>
    var saom = '';//成功的<{:C("scanorder.lang_name")}>号
    $("#saom").keydown(function (event) {
        if (event.keyCode == 13) {
            if ($("#saom").val() == '') {
				play_audio_file('failed');
                alerts('<{:C("scanorder.lang_name")}>号不能为空！');
            }
        }
    });
    $("#sub").on("click", function () {
        if ($("#saom").val() == '') {
            alerts('<{:C("scanorder.lang_name")}>号不能为空！');
			play_audio_file('failed');
            return false;
        }
        if ($("#pack_weight").val() == '') {
            alerts('重量不能为空！');
			play_audio_file('failed');
            return false;
        }
        $.post("__APP__/ScanOrder/weighed", {order_no:$("#saom").val(),weight:$("#pack_weight").val()}, function (msg) {
            if (msg.flag == 0) {
				play_audio_file('failed');
                alerts(msg.data);
            }
            else {
				play_audio_file('success');
                alerts(msg.data);
                $("input[type=text]").prop("value",'');
            }
        },'json');

    });
    function alerts(msg) {
        var index = layer.open({
            type: 0,
            title: '系统提示',
            content: msg,
            shift: 2,
            btn: ['知道了'],
            time: 1200,
            offset: '120px',
            yes: function () {
                layer.close(index);
            }
        });
        $("#saom").prop("value", '');
    }
	function play_audio_file(filename) {
        var url = "__PUBLIC__";
        if ($("audio").length == 0) {
            $("body").append($("<audio src='' autoplay></audio>"));
        }
        $("audio").attr('src', url + '/Admin/Voice/'+filename+'.wav');
    }
</script>
</body>
